package Test;

import java.util.Random;

public class RandomArrayStats {
    public static void main(String[] args) {
        int[] numbers = new int[10];
        Random rand = new Random();

        // 随机生成10个0到99的数
        for (int i = 0; i < numbers.length; i++) {
            numbers[i] = rand.nextInt(100);
        }

        // 计算最大值、最小值、和
        int max = numbers[0];
        int min = numbers[0];
        int sum = 0;

        for (int num : numbers) {
            if (num > max) {
                max = num;
            }
            if (num < min) {
                min = num;
            }
            sum += num;
        }

        double average = sum / (double) numbers.length;

        // 输出结果
        System.out.println("随机生成的数组: ");
        for (int num : numbers) {
            System.out.print(num + " ");
        }
        System.out.println("\n最大值: " + max);
        System.out.println("最小值: " + min);
        System.out.println("数组元素之和: " + sum);
        System.out.println("平均值: " + average);
    }
}